package net.cloudcodex.client;

import java.util.List;

import net.cloudcodex.client.campaign.presenter.CampaignConfigPresenter;
import net.cloudcodex.client.campaign.presenter.CampaignCreationPresenter;
import net.cloudcodex.client.campaign.presenter.CampaignPresenter;
import net.cloudcodex.client.campaign.presenter.CampaignsPresenter;
import net.cloudcodex.client.campaign.view.CampaignView;
import net.cloudcodex.client.character.detail.cache.CharacterDetailPool;
import net.cloudcodex.client.character.detail.presenter.CharacterDetailPresenter;
import net.cloudcodex.client.character.handler.CharacterDescriptionEventHandler;
import net.cloudcodex.client.character.presenter.CharacterDescriptionPopupPresenter;
import net.cloudcodex.client.character.presenter.CharacterDescriptionPresenter;
import net.cloudcodex.client.character.presenter.CharacterNPCCreationPresenter;
import net.cloudcodex.client.character.presenter.CharacterPlayerInvitationPresenter;
import net.cloudcodex.client.character.presenter.CharacterPresenter;
import net.cloudcodex.client.character.presenter.CharactersPresenter;
import net.cloudcodex.client.home.presenter.HomePresenter;
import net.cloudcodex.client.main.presenter.MainPresenter;
import net.cloudcodex.client.main.presenter.RegisterPresenter;
import net.cloudcodex.client.main.view.MainViewImpl;
import net.cloudcodex.client.storyboard.player.PlayerBoardModule;
import net.cloudcodex.client.storyboard.player.presenter.PlayerBoardPresenter;
import net.cloudcodex.client.util.Container;
import net.cloudcodex.shared.dto.campaign.character.CharacterDescriptionDTO;
import net.cloudcodex.shared.dto.campaign.character.CharacterHeaderDTO;
import net.cloudcodex.shared.dto.home.CampaignSummaryDTO;
import net.cloudcodex.shared.dto.home.CharacterSummaryDTO;
import net.cloudcodex.shared.dto.home.HomeDTO;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.IsWidget;
import com.mvp4g.client.annotation.Debug;
import com.mvp4g.client.annotation.Debug.LogLevel;
import com.mvp4g.client.annotation.Event;
import com.mvp4g.client.annotation.Events;
import com.mvp4g.client.annotation.Start;
import com.mvp4g.client.annotation.module.ChildModule;
import com.mvp4g.client.annotation.module.ChildModules;
import com.mvp4g.client.annotation.module.LoadChildModuleError;
import com.mvp4g.client.event.EventBus;

/**
 * 
 * 
 * @author ADaroussin
 */
@Debug(logLevel = LogLevel.DETAILED)
@Events(startView = MainViewImpl.class)
@ChildModules(@ChildModule(moduleClass = PlayerBoardModule.class, autoDisplay = false))
public interface CloudCodexEventBus extends EventBus {

	@Start
	@Event(handlers = MainPresenter.class)
	public void start();

	@Event(handlers = MainPresenter.class)
	public void addTab(IsWidget tab, String tabName);

	@Event(handlers = MainPresenter.class)
	public void selectTab(IsWidget tab);

	@LoadChildModuleError
	@Event(handlers = MainPresenter.class)
	public void displayErrorMessage(Throwable reason);

	@Event(handlers = MainPresenter.class)
	public void displayAlertMessage(String message);

	@Event(handlers = HomePresenter.class)
	public void initHomeTab(HomeDTO homeDTO);

	@Event(handlers = CampaignsPresenter.class)
	public void initCampaignsTab(List<CampaignSummaryDTO> campaignSummaryDTOs);

	@Event(handlers = CharactersPresenter.class)
	public void initCharactersTab(List<CharacterSummaryDTO> charactersSummaryDTO);

	@Event(handlers = CharacterDescriptionEventHandler.class)
	public void getCharacterDescription(long campaignId, long characterId, Long byCharacterId,
			AsyncCallback<CharacterDescriptionDTO> callback);

	@Event(handlers = CharacterDescriptionEventHandler.class)
	public void updateCharacterDescription(long campaignId, long characterId, Long byCharacterId,
			CharacterHeaderDTO characterHeader, CharacterDescriptionDTO characterDescription);

	@Event(handlers = RegisterPresenter.class)
	public void showRegisterPopup();

	@Event(handlers = { CampaignsPresenter.class, CampaignPresenter.class, CharacterPresenter.class,
			CharacterDescriptionPopupPresenter.class })
	public void setNickName(String nickName);

	@Event(handlers = { CampaignPresenter.class, CharacterDescriptionPopupPresenter.class })
	public void setUserId(long userId);

	@Event(handlers = CampaignsPresenter.class)
	public void initCharacterDescription(Long campaignID, Long characterID);

	@Event(handlers = CharacterDescriptionPopupPresenter.class)
	public void showCharacterDescriptionPopup(long campaignId, CharacterHeaderDTO ownerSelectedCharacterHeaderDTO,
			CharacterHeaderDTO clickedCharacterHeaderDTO);

	@Event(modulesToLoad = PlayerBoardModule.class)
	public void newPlayerBoard(long campaignId, long characterId, Container<PlayerBoardPresenter> container);

	@Event(handlers = { CharacterDescriptionPresenter.class, CampaignConfigPresenter.class })
	public void updateButtonEnable(boolean isEnable, String textAreaID);

	@Event(handlers = CharactersPresenter.class)
	public void addCharacterTab(IsWidget view, String name, Long characterId);

	@Event(handlers = CampaignsPresenter.class)
	public void addCampaignTab(CampaignView view, String name, long id);

	@Event(handlers = CampaignsPresenter.class)
	public void selectCampaignTab(Long campaignId, String selectedContent);

	@Event(handlers = CharactersPresenter.class)
	public void selectCharacterTab(Long characterId, String selectedContent);

	@Event(handlers = CampaignCreationPresenter.class)
	public void createNewCampaign(String nickname);

	@Event(handlers = { CampaignsPresenter.class, HomePresenter.class })
	public void addNewCampaign(CampaignSummaryDTO campaignSummaryDTO);

	@Event(handlers = { CampaignsPresenter.class, HomePresenter.class })
	public void updateCampaign(CampaignSummaryDTO campaignSummaryDTO);

	@Event(handlers = CharacterNPCCreationPresenter.class)
	public void createNewNPC(CampaignSummaryDTO campaignSummaryDTO);

	@Event(handlers = CampaignsPresenter.class)
	public void addNewCharacterInCampaign(long campaignId, CharacterHeaderDTO characterHeaderDTO);

	@Event(handlers = CharacterPlayerInvitationPresenter.class)
	public void inviteNewPlayer(CampaignSummaryDTO campaignSummaryDTO);

	@Event(handlers = CharacterDetailPool.class)
	public void newCharacterDetail(Long byCharacterId, CharacterSummaryDTO characterSummary,
			Container<CharacterDetailPresenter> container);

}
